package com.lemon.boot.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lemon.boot.dto.LogDTO;
import com.lemon.boot.po.LogPO;
import com.lemon.boot.service.ILogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 李猛
 * @datetime 2024/3/3 11:18
 * @description 类对象
 */
@Log4j2
@Api(tags = "日志管理")
@RestController
@RequestMapping("log")
public class LogController {
    @Resource
    private ILogService iLogService;

    /**
     * 根据ID查询数据
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "根据ID查询数据")
    @GetMapping("get/{id}")
    public LogPO get(@PathVariable("id") Long id) {
        return iLogService.get(id);
    }

    /**
     * 根据实体类查询分页数据
     *
     * @param logDTO
     * @return
     */
    @ApiOperation(value = "根据实体类查询分页数据")
    @GetMapping("page")
    public Page<LogPO> page(LogDTO logDTO) {
        return iLogService.page(logDTO);
    }

    /**
     * 导出
     *
     * @param logDTO
     */
    @ApiOperation(value = "导出")
    @PostMapping("export")
    public void export(@RequestBody LogDTO logDTO) {
        iLogService.export(logDTO);
    }
}
